#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "tools\fn_buildingTypeFilter.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>

// This is a very demanding function, only use at the beginning of missions but never later on!

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_result"];
//DEFAULT_PARAM(_object,0,objNull);

_result = [];

/// @FUNCTION
/// @NAME XfBuildingFilteredList
/// @ACCESS Public
/// @MP True
/// @PARAM Scalar The total number of positions required (-1 = ignore filter)
/// @PARAM Scalar The total number of combat positions required (-1 = ignore filter) @DEFAULT -1
/// @PARAM Scalar The total number of hiding positions required (-1 = ignore filter) @DEFAULT -1
/// @PARAM Scalar The total number of sniper positions required (-1 = ignore filter) @DEFAULT -1
/// @RETURN Array Return the list of building names matching the criterias
/// @REQUIRE Nothing
/// @EXAMPLE _house_list = [-1,-1,4] call XfBuildingFilteredList;
// XfBuildingFilteredList = {
	// private ["_buildings","_bld_array", "_type", "_total", "_combat","_hide","_sniper", "_total_cnt", "_combat_cnt","_hide_cnt","_sniper_cnt","_i","_is_match"];
	// // diag_log Format["(%1)[%2]: %3: %4",diag_tickTime,"building_position.sqf","XfBuildingFilteredList", _this];
	// _buildings = [];
	// if (count _this <= 0) exitWith {diag_log Format["(%1)[%2]: %3: [%4] (%5) %6",diag_tickTime,"building_position.sqf","XfBuildingFilteredList", "Requires at least one param", _buildings];};
	// _total = -1;
	// _combat = -1;
	// _hide = -1;
	// _sniper = -1;
	// _total = _this select 0;
	// if (count _this > 1) then { _combat = _this select 1; };
	// if (count _this > 2) then { _hide = _this select 2; };
	// if (count _this > 3) then { _sniper = _this select 3; };
	
	// for "_i" from 0 to ((count BUILDING_POSITION_INDEXER) - 1) step 1 do {
		// _bld_array = BUILDING_POSITION_INFOS select _i;
		// _combat_cnt = count (_bld_array select 0);
		// _hide_cnt = count (_bld_array select 1);
		// _sniper_cnt = count (_bld_array select 2);
		// _total_cnt = _combat_cnt + _hide_cnt + _sniper_cnt;
		// // diag_log Format["(%1)[%2]: %3: [%4] (%5) %6",diag_tickTime,"building_position.sqf","XfBuildingFilteredList", [(BUILDING_POSITION_INDEXER select _i),_total_cnt, _combat_cnt, _hide_cnt, _sniper_cnt]];
		// _is_match = true;
		// if (_combat_cnt < _combat) then { _is_match = false; };
		// if (_hide_cnt < _hide) then { _is_match = false; };
		// if (_sniper_cnt < _sniper) then { _is_match = false; };
		// if (_total_cnt < _total) then { _is_match = false; };
		// if (_is_match) then {
			// _buildings set [count _buildings, (BUILDING_POSITION_INDEXER select _i)];
		// };
	// };
	// // diag_log Format["(%1)[%2]: %3: [%4] (%5) %6",diag_tickTime,"building_position.sqf","XfBuildingFilteredList", _buildings];
	// _buildings;
// };

TRACE_1("End",_result);
TMFPROFILERSTOP;
_result